//
//  day_of_year.c
//  project-c
//
//  Created by 小演员的MacBook on 2023/10/15.
//

#include <stdio.h>

//输入年月日，判断是当年的第几天
void day_of_year(int year, int month, int day) {
    int sum = day;
    for (int i = 1; i < month; i++) {
        switch (i) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                sum += 31;
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                sum += 30;
                break;
            case 2:
                if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {//闰年
                    sum += 29;
                } else {//平年
                    sum += 28;
                }
                break;
            default:
                printf("请输入正确的1-12月份！\n");
                return;
                break;
        }
    }
    printf("%d年%d月%d日 是所在年的第%d天！\n", year, month, day, sum);
}
